#!/bin/sh

### BEGIN INIT INFO
# Provides: lldpd
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $syslog $network $net-snmp
# Should-Stop: $syslog $network $net-snmp
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: LLDP daemon
# Description: 802.1ab (LLDP) daemon
### END INIT INFO


# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
LLDPD_BIN=/usr/sbin/lldpd
test -x $LLDPD_BIN || { echo "$LLDPD_BIN not installed"; 
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

# Check for existence of needed config file and read it
LLDPD_CONFIG=/etc/sysconfig/lldpd
test -r $LLDPD_CONFIG || { echo "$LLDPD_CONFIG not existing";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 6; fi; }

# Read config	
. $LLDPD_CONFIG

. /etc/rc.status

# Reset status of this service
rc_reset

case "$1" in
    start)
	echo -n "Starting lldpd "
	/sbin/startproc $LLDPD_BIN
	rc_status -v
	;;
    stop)
	echo -n "Shutting down lldpd "
	/sbin/killproc -TERM $LLDPD_BIN
	rc_status -v
	;;
    try-restart|condrestart)
	$0 status
	if test $? = 0; then
		$0 restart
	else
		rc_reset	# Not running is not a failure.
	fi
	rc_status
	;;
    restart)
	$0 stop
	$0 start

	rc_status
	;;
    force-reload)
	$0 try-restart
	rc_status
	;;
    reload)
	# Does not support reload
	rc_failed 3
	rc_status -v
	;;
    status)
	echo -n "Checking for service lldpd "
	/sbin/checkproc $LLDPD_BIN
	rc_status -v
	;;
    probe)
	;;
    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
	exit 1
	;;
esac
rc_exit

